

package com.gs.netty.support.resolver;


import com.gs.netty.core.resolver.args.AbstractHandlerMethodArgumentResolver;
import com.gs.netty.core.resolver.args.HandlerMethodArgumentResolver;
import com.gs.netty.websocket.remoting.req.Request;
import org.springframework.core.MethodParameter;

import java.util.List;

/**
 * 方法参数解析器
 */

public class HandlerMethodArgumentResolverComposite extends AbstractHandlerMethodArgumentResolver<Request> {

	public HandlerMethodArgumentResolverComposite() {
	}

	@Override
	public Object resolveArgument(MethodParameter parameter, Request request) throws Exception {
		// 找到参数解析器
			HandlerMethodArgumentResolver resolver = getArgumentResolver(parameter);
		if (resolver == null) {
			throw new IllegalArgumentException("Unsupported parameter type [" +
					parameter.getParameterType().getName() + "]. supportsParameter should be called first.");
		}
		// 参数解析
		return resolver.resolveArgument(parameter,request);
	}

	@Override
	public HandlerMethodArgumentResolver addArgumentResolvers(HandlerMethodArgumentResolver... resolvers) {
		return super.addArgumentResolvers(resolvers);
	}
	@Override

	public HandlerMethodArgumentResolver addArgumentResolvers(List<HandlerMethodArgumentResolver> resolvers) {
		return super.addArgumentResolvers(resolvers);
	}
}
